#ifndef FTMODEL_H
#define FTMODEL_H

#include <QObject>
#include <QAbstractListModel>
#include <QTimer>

/* 模型类 继承自QAbstractListModel，新建该类时务必选上 Q_OBJECT */
class FtGridModel : public QAbstractListModel
{
    Q_OBJECT
public:
    FtGridModel();

    /* 自定义角色名 */
    enum RoleNames
    {
        RandValue          = Qt::UserRole + 1,
    };

private:
    /* 数据刷新定时器，UI上的数据刷新通过该定时器实现 */
    QTimer timer;

    /* 必要的几个方法 */
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QHash<int,QByteArray> roleNames() const override;

private slots:
    void onTimeout();
};

#endif // FTMODEL_H
